package gui.factory;

import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.tables.Column;
import org.uqbar.arena.widgets.tables.Table;

import aOrganizar.Itinerario;

import com.uqbar.commons.collections.Transformer;

public abstract class TableFactory {
	
	
	
	public Table<Itinerario> createTable(Panel mainPanel, String resultsProperty, String selectedProperty) {
		Table<Itinerario> table = new Table<Itinerario>(mainPanel, Itinerario.class);
		table.bindItemsToProperty(resultsProperty);
		table.bindValueToProperty(selectedProperty);
		this.defineColumns(table);
		return table;
	}
	
	
	protected abstract void defineColumns(Table<Itinerario> table);

	
	/**
	 * @param table
	 */
	protected void addColumn(Table<Itinerario> table, String titulo, Integer size, Transformer<Itinerario,String> transformer) {
		new Column<Itinerario>(table)
		.setTitle(titulo)
		.setFixedSize(size)
		.bindContentsToTransformer(transformer);
	}

}
